<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p></p>
    <script>
        var pEle = document.querySelector("p");
        // 接收参数
        var str = decodeURI(window.location.search);

        var obj = formatSearch(str);
        // console.log(obj);
        pEle.innerHTML = `姓名是${obj.username}密码是:${obj.pwd}`;



        function formatSearch(str) {
            str = str.substr(1);
            var arr = str.split("&");
            var obj = {};
            arr.forEach(function (item) {
                var newarr = item.split("=");
                obj[newarr[0]] = newarr[1];
            })
            return obj;
        }

    </script>
</body>
</html>